package com.movisol.messenger.views.controls;

import android.content.Context;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.TextView.OnEditorActionListener;

import com.movisol.messenger.R;

public class EmailTab extends LinearLayout{

	private Button btOkEmail;
	private Button btCancelEmail;
	private EditText edTxtEmail;
	private TextView errorMessage;
	private String btOkText;
	private String btCancelText;
	
	public EmailTab(Context context, String btOkText, String btCancelText) {
		super(context);
		String infService = Context.LAYOUT_INFLATER_SERVICE;
		LayoutInflater li = (LayoutInflater)context.getSystemService(infService);
		li.inflate(R.layout.emailtab, this, true);
		
		this.btOkText = btOkText;
		this.btCancelText = btCancelText;
		initializeControls();
	}

	private void initializeControls() {
		
		edTxtEmail = (EditText) findViewById(R.id.emailLogin);		
		edTxtEmail.setOnEditorActionListener(new OnEditorActionListener() {
			
			@Override
			public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
				// TODO Auto-generated method stub
				return false;
			}
		});

		btOkEmail = (Button) findViewById(R.id.btOkEmail);
		btOkEmail.setText(btOkText);
		
		errorMessage = (TextView) findViewById(R.id.tvErrorMessageEmail);
		
		btCancelEmail = (Button) findViewById(R.id.btCancelEmail);
		if(btCancelText != null)
		{
			btCancelEmail.setVisibility(View.VISIBLE);
			btCancelEmail.setText(btCancelText);
		}
		else
			btCancelEmail.setVisibility(View.GONE);
		
	}

	/**
	 * @return the btSignIn
	 */
	public Button getBtOkEmail() {
		return btOkEmail;
	}
	
	/**
	 * @return the btSignIn
	 */
	public Button getBtCancelEmail() {
		return btCancelEmail;
	}

	/**
	 * @return the edTxtEmail
	 */
	public EditText getEdTxtEmail() {
		return edTxtEmail;
	}
	
	public void showErrorMessage(String error)
	{
		errorMessage.setText(error);
		errorMessage.setVisibility(View.VISIBLE);
	}
	
	public void hideErrorMessage()
	{
		errorMessage.setVisibility(View.INVISIBLE);
	}	
	

}
